package com.example.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.system.entity.PathKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

@Mapper
public interface PathKeyMapper extends BaseMapper<PathKey> {
    @Select("SELECT COUNT(*) > 0 FROM path_key WHERE set_time >= #{begin} AND set_time <= #{end} ")
    boolean existsByStartTimeAndEndTime(@Param("begin") LocalDateTime begin, @Param("end") LocalDateTime end);

    @Select("SELECT random_path_key FROM path_key WHERE set_time >= #{begin} AND set_time <= #{end} ")
    String findRandomPathKeyByStartTimeAndEndTime(@Param("begin") LocalDateTime begin, @Param("end") LocalDateTime end);

    int addByPathKey(PathKey pathKey);
}
